# # core/page/slider_verify_page_manual.py
# from core.base.page_base import BasePage
# from selenium.webdriver.common.by import By
# from selenium.webdriver import ActionChains
# from selenium.webdriver.support.ui import WebDriverWait
# from selenium.webdriver.support import expected_conditions as EC
# import time
#
# class SliderVerifyPage(BasePage):
#     """滑块验证页：仅负责“滑块验证URL”的元素和方法（单一职责）"""
#     # 1. 手动定义当前URL的locators（仅滑块相关元素，无其他URL逻辑）
#     locators = {
#         "slider_block": (By.CLASS_NAME, "slider-block"),       # 滑块本体
#         "slider_track": (By.CLASS_NAME, "slider-track"),       # 滑块轨道
#         "slider_success_icon": (By.CLASS_NAME, "success-icon") # 验证成功标识
#     }
#
#     # 2. 封装当前URL的核心方法（滑块拖动，仅管滑块逻辑）
#     def drag_slider_to_verify(self, wait_time: int = 10) -> None:
#         """
#         拖动滑块完成验证（模拟真人操作，避免反爬）
#         :param wait_time: 等待验证成功的超时时间
#         """
#         # 等待滑块元素加载（基于BasePage的描述符+显式等待）
#         slider = WebDriverWait(self.driver, wait_time).until(
#             EC.element_to_be_clickable(self.locators["slider_block"])
#         )
#         track = self.slider_track  # 描述符自动定位轨道元素
#
#         # 计算拖动距离（轨道宽度 - 滑块宽度）
#         track_width = track.size["width"]
#         slider_width = slider.size["width"]
#         drag_distance = track_width - slider_width
#
#         # 模拟真人拖动（分3段，避免一次性拖动被反爬）
#         action = ActionChains(self.driver)
#         action.click_and_hold(slider).perform()
#         time.sleep(0.2)  # 初始停顿
#
#         # 第一段：拖动50%距离
#         action.move_by_offset(drag_distance * 0.5, 0).perform()
#         time.sleep(0.3)
#
#         # 第二段：拖动剩余50%距离
#         action.move_by_offset(drag_distance * 0.5, 0).perform()
#         time.sleep(0.1)
#
#         # 松开滑块
#         action.release().perform()
#
#         # 等待验证成功（确保后续步骤能正常执行）
#         WebDriverWait(self.driver, wait_time).until(
#             EC.visibility_of_element_located(self.locators["slider_success_icon"])
#         )